﻿using System.Configuration;

namespace LeanBoard
{
    public class TeamsConfigSection : ConfigurationSection
    {
        [ConfigurationProperty("teams", IsRequired = true)]
        public TeamsElementCollection Teams
        {
            get { return (TeamsElementCollection)base["teams"]; }
        }
    }

    public class TeamsElementCollection : ConfigurationElementCollection
    {

        public TeamsElement this[int index]
        {
            get { return base.BaseGet(index) as TeamsElement; }
        }

        public TeamsElement this[object key]
        {
            get
            {
                return base.BaseGet(key) as TeamsElement;
            }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new TeamsElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((TeamsElement)element).TeamName;
        }
    }

    public class TeamsElement : ConfigurationElement
    {
        [ConfigurationProperty("teamName", IsRequired = true)]
        public string TeamName
        {
            get
            {
                return this["teamName"] as string;
            }
        }

        [ConfigurationProperty("displayName", IsRequired = true)]
        public string DisplayName
        {
            get
            {
                return this["displayName"] as string;
            }
        }

        [ConfigurationProperty("scheduledRelease", IsRequired = true)]
        public string ScheduledRelease
        {
            get
            {
                return this["scheduledRelease"] as string;
            }
        }
        
        [ConfigurationProperty("wip", IsRequired = true)]
        public int Wip
        {
            get
            {
                return (int)this["wip"];
            }
        }
    }
}